package com.learn.mvc.handler;

import com.learn.mvc.entity.Address;
import com.learn.mvc.entity.Product;
import com.learn.mvc.entity.Student;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class ProductHandler {

    Logger logger = LoggerFactory.getLogger(this.getClass());
    @RequestMapping("/save/product")
    public String saveProduct(Product product, BindingResult bindingResult) {

        if (bindingResult.hasErrors()) {
            return "error";
        }


        logger.debug(product.toString());

        return "target";
    }

    @RequestMapping("/save/student")
    public String saveStudent(Student student) {
        logger.debug(student.getAddress().toString());
        // System.out.println(student.toString());
        return "target";
    }
}
